package utils.nfc.xml
{

		public class NfcTag
		{
			public static const MODE_READER:String 		= "reader";
			public static const MODE_WRITER:String 		= "writer";
			public static const MODE_EMULATOR:String 	= "emulator";
			
			private var tagID:int;	
			private var contentRefID:String;
			private var recordArray:Array;
			private var led:Led;
			private var mode:String;
			
			
			public function NfcTag(tagID:int, ledStatus:String = 'permanent,green' , contentRefID:String="",  recordArray:Array = null, mode:String = MODE_EMULATOR){
				this.tagID = tagID;
				this.contentRefID = contentRefID;
				this.led = new Led(ledStatus);
				this.recordArray = recordArray;
				this.mode = mode;
				
			}
			
			public function toXML():XML{
				var nfcTag:XML = <nfcTag/>;
				nfcTag.@tagID = tagID;
				nfcTag.@mode = mode;
				
				if (contentRefID != "")
					nfcTag.@contentRefID = contentRefID;
				
				nfcTag.appendChild(led.toXML());

				if (recordArray != null){
					for (var i:int = 0; i < recordArray.length; i++) 
					{
						var curRecord:Record = recordArray[i];
						nfcTag.appendChild(curRecord.toXML());
					}
				}
				
				return nfcTag;
			}
		}
}